package com.crm.dao.after_sale;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.crm.pojo.AftetSaleServer;

public interface AfterSaleServiceDao extends CrudRepository<AftetSaleServer, Long> {
	/**
	 * 根据服务编号查询售后服务
	 * @param serverId
	 * @return
	 */
	@Query("from AftetSaleServer a where a.serverId = ?1 and a.aftetSaleServerIsDel = '否'")
	public List<AftetSaleServer> findOneNotDel(Long serverId, Pageable pageable);
	
	
	/**
	 * 分页查询所有没有被删除的售后服务
	 * @param pageable
	 * @return
	 */
	@Query("from AftetSaleServer a where a.aftetSaleServerIsDel = '否'  order by a.serverId desc")
	public List<AftetSaleServer> findAllNotDelBypage(Pageable pageable);
	/**
	 * 查询没有被删除的售后服务的数量
	 * @return
	 */
	@Query("select count(*) from AftetSaleServer a where a.aftetSaleServerIsDel = '否'")
	public Long countAllNotDelBypage();
	
	/**
	 * 根据服务主题查询客户服务
	 * @param theme
	 * @return
	 */
	@Query("from AftetSaleServer a where a.theme like ?1 and a.aftetSaleServerIsDel = '否'")
	public List<AftetSaleServer> findByTheme(String theme, Pageable pageable);
	
	/**
	 * 根据服务主题查询客户服务的数量
	 * @param theme
	 * @return
	 */
	@Query("select count(*) from AftetSaleServer a where a.theme like ?1 and a.aftetSaleServerIsDel = '否'")
	public Long countByTheme(String theme);
}
